package com.firstjianmo.broadcasttest2;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

/**
 * Created by pc on 2016/12/4.
 */

public class AnotherBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String msg = intent == null ? "" : intent.getStringExtra("msg");
        Toast.makeText(context, "received in AnotherBroadcastReceiver; " + msg, Toast.LENGTH_LONG).show();

        Bundle bundle = getResultExtras(true);//true：前一个广播没有结果时创建新的Bundle；false：不创建Bundle
        bundle.putString("msg", "BroadcastTest2篡改了广播信息");
        //将bundle数据放入广播中传给下一个广播接收者
        setResultExtras(bundle);

        //abortBroadcast(); // 截断广播 接收的是有序广播时才可以拦截
    }
}
